package common.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.ComponentScan;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/**
 * @author 贾伟焘
 * @version 1.0
 * @Description swagger配置类
 * @Date 2022/7/8 9:19
 */
@Configuration
public class SwaggerConfig {
    /**
     * 配置swagger2核心配置 docket
     */
    @Bean
    public Docket createRestApi() {
        // 指定api类型为swagger2
        return new Docket(DocumentationType.SWAGGER_2)
                // 用于定义api文档汇总信息
                .apiInfo(apiInfo())
                .select()
                // 所有controller
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                // 文档页标题
                .title("api接口")
                // 联系人信息
                .contact(new Contact("",
                        "",
                        ""))
                // 文档版本号
                .version("1.0.1")
                // 详细信息
                .description("提供公共的api文档")
                // 网站地址
                .termsOfServiceUrl("")
                .build();
    }
}
